using System.Collections.Generic;
using NHibernate;

namespace DMS.DAOs.NH
{
    public class GenericDAO<T> : AbstractDAO where T : class
    {
        public GenericDAO(ISessionFactory sessionFactory) : base(sessionFactory)
        {}

        public T GetById(int id)
        {
            return Session.Get<T>(id);
        }

        public void Persist(T entity)
        {
            Session.Persist(entity);
        }

        public void Delete(T entity)
        {
            Session.Delete(entity);
        }

        public ICollection<T> GetAll()
        {
            return Session.CreateCriteria<T>().List<T>();
        }

    }
}